AddCSLuaFile( "shared.lua" )

SWEP.Base = "weapon_cs_base"

SWEP.Spawnable = true
SWEP.AdminSpawnable = true

SWEP.Primary.Sound = Sound("Weapon_USP.Single")
SWEP.Primary.Recoil = 0.15
SWEP.Primary.Damage = 20
SWEP.Primary.NumShots = 1
SWEP.Primary.Cone = 0.03
SWEP.Primary.ClipSize = 12
SWEP.Primary.Delay = 0.1
SWEP.Primary.DefaultClip = 50
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "smg1"

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"

function SWEP:Think()
	if !self.BaseCone then self.BaseCone = self.Primary.Cone end
	local AccMod = 0
		
	if SERVER and self.Owner:Crouching() and self.Owner:IsOnGround() then
		AccMod = AccMod + 0.01
		self.Owner:SetNWInt("crouch",1)
	elseif SERVER then
		self.Owner:SetNWInt("crouch",0)
	end
	if CLIENT and self.Owner:GetNWInt("crouch") == 1 then
		AccMod = AccMod + 0.01
	end
	if self.Owner:GetVelocity():Length() < 25 then
		AccMod = AccMod + 0.01
	elseif self.Owner:GetVelocity():Length() > 50 then
		AccMod = AccMod - 0.01
	end
		
		
	if !self.Owner:IsOnGround() then
		AccMod = AccMod - 0.04
	end
	self.Primary.Cone = math.Clamp(self.BaseCone-AccMod,0.005,0.1)
end

/* Not needed when not tracing all shots
function SWEP:PrimaryAttack() //when +attack1 happens
 
	// Make sure we can shoot first
	if ( !self:CanPrimaryAttack() ) then return end
	
	local Spread = Vector(math.Rand(-self.Primary.Cone,self.Primary.Cone),math.Rand(-self.Primary.Cone,self.Primary.Cone),math.Rand(-self.Primary.Cone,self.Primary.Cone))
	
	local bullet = {} //creates a table for the properties of the bullet
	bullet.Num 		= self.Primary.NumShots //number of bullets you are shooting
	bullet.Src 		= self.Owner:GetShootPos() // Source, where you are standing
	bullet.Dir 		= self.Owner:GetAimVector()+Spread // direction of bullet, where you are looking
	bullet.Spread 	= Vector( 0, 0, 0 ) // spread of bullet, how accurate it is
	bullet.Tracer	= 0	// this doesn't really affect anything
	bullet.Force	= self.Force // how powerful it is
	bullet.Damage	= self.Damage //how much damage it does to people
	bullet.AmmoType = self.Primary.Ammo //what type of ammo you are using

	self.Owner:FireBullets( bullet ) //actually shoots the bullet.
	
	--Trace all shots
	if CLIENT then
		for i = 1, 10 do
			--timer.Create("recoilshot"..BCount.."stage"..i,0.001*i,1,function()
				self.Owner:SetEyeAngles(self.Owner:GetAimVector():Angle()-Angle(self.Primary.Recoil*20/i,0,0))
				print(i)
			--end)
		end
	end
	
	if SERVER then
		for k,v in pairs(player.GetAll()) do
			v:SendLua("gamemode.Call(\"ShotFired\",player.GetByID("..self.Owner:EntIndex().."),Vector("..Spread[1]..","..Spread[2]..","..Spread[3].."))")
		end
	end
	
	self.Weapon:EmitSound( self.Primary.Sound )
	// this makes the sound, which I specified earlier in the code

	self.BaseClass.ShootEffects(self);
	//this makes the shooting animation for the 357 for view model and world model

	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
	//this sets the delay for the next primary and secondary fires.
 
	self:TakePrimaryAmmo(1) //removes 1 ammo from our clip
end //end our function
*/